﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Godot.core.io
{
    using SysMethodInfo = System.Reflection.MethodInfo;

    public partial class ConfigFile : Reference
    {
        public void set_value(string p_section, string p_key, Variant p_value)
        {
            throw new System.NotImplementedException();
        }

	    public Variant get_value(string p_section, string p_key)
        {
            throw new System.NotImplementedException();
        }

	    public bool has_section(string p_section)
        {
            throw new System.NotImplementedException();
        }

	    public bool has_section_key(string p_section, string p_key)
        {
            throw new System.NotImplementedException();
        }

	    public void get_sections(ref List<string> r_sections)
        {
            throw new System.NotImplementedException();
        }

	    public void get_section_keys(string p_section, ref List<string> r_keys)
        {
            throw new System.NotImplementedException();
        }

	    public Error save(string p_path)
        {
            throw new System.NotImplementedException();
        }

        public Error load(string p_path)
        {
            throw new System.NotImplementedException();
        }

        protected List<string> _get_sections()
        {
            throw new System.NotImplementedException();
        }

	    protected  List<string> _get_section_keys(string p_section)
        {
            throw new System.NotImplementedException();
        }

        protected static new void _bind_methods()
        {      
	        ObjectTypeDB.bind_method(_MD("set_value","section","key","value"),typeof(ConfigFile).GetMethod("set_value", Misc.BindingFlags_Greedy));
	        ObjectTypeDB.bind_method(_MD("get_value","section","key"),typeof(ConfigFile).GetMethod("get_value", Misc.BindingFlags_Greedy));

	        ObjectTypeDB.bind_method(_MD("has_section","section"),typeof(ConfigFile).GetMethod("has_section", Misc.BindingFlags_Greedy));
	        ObjectTypeDB.bind_method(_MD("has_section_key","section","key"),typeof(ConfigFile).GetMethod("has_section_key", Misc.BindingFlags_Greedy));

	        ObjectTypeDB.bind_method(_MD("get_sections"),typeof(ConfigFile).GetMethod("_get_sections", Misc.BindingFlags_Greedy));
	        ObjectTypeDB.bind_method(_MD("get_section_keys"),typeof(ConfigFile).GetMethod("_get_section_keys", Misc.BindingFlags_Greedy));

	        ObjectTypeDB.bind_method(_MD("load:Error","path"),typeof(ConfigFile).GetMethod("load", Misc.BindingFlags_Greedy));
	        ObjectTypeDB.bind_method(_MD("save:Error","path"),typeof(ConfigFile).GetMethod("save", Misc.BindingFlags_Greedy));
        }
    }

    public partial class ConfigFile
    {
        #region OBJ_TYPE(ConfigFile,Reference)
        public override string get_type() { return "ConfigFile"; }

        public override string get_save_type() { return get_type(); } //type stored when saving

        public override StringName get_type_name() { return (StringName)get_type_static(); }

        public override bool is_type(string p_type) { return (p_type == "ConfigFile") ? true : base.is_type(p_type); }

        protected override void _initialize_typev() { initialize_type(); }

        protected override bool _setv(StringName p_name, Variant p_property)
        {
            if (base._setv(p_name, p_property))
                return true;

            if (typeof(ConfigFile).GetMethod("_set", Misc.BindingFlags_Greedy) != typeof(Reference).GetMethod("_set", Misc.BindingFlags_Greedy))
            {
                return _set(p_name, p_property);
            }

            return false;
        }

        protected override bool _getv(StringName p_name, ref Variant r_property)
        {
            if (typeof(ConfigFile).GetMethod("_get", Misc.BindingFlags_Greedy) != typeof(Reference).GetMethod("_get", Misc.BindingFlags_Greedy))
            {
                if (_get(p_name, ref r_property))
                    return true;
            }

            return base._getv(p_name, ref r_property);
        }

        protected override void _get_property_listv(ref List<PropertyInfo> p_list, bool p_reversed)
        {
            if (!p_reversed)
            {
                base._get_property_listv(ref p_list, p_reversed);
            }

            p_list.Add(new PropertyInfo(Variant.Type.NIL, get_type_static(), PropertyHint.PROPERTY_HINT_NONE, "", (int)PropertyUsageFlags.PROPERTY_USAGE_CATEGORY));

            if (!_is_gpl_reversed())
                ObjectTypeDB.get_property_list("ConfigFile", ref p_list, true);

            if (typeof(ConfigFile).GetMethod("_get_property_list", Misc.BindingFlags_Greedy) != typeof(Reference).GetMethod("_get_property_list", Misc.BindingFlags_Greedy))
            {
                _get_property_list(ref p_list);
            }

            if (_is_gpl_reversed())
                ObjectTypeDB.get_property_list("ConfigFile", ref p_list, true);

            if (p_reversed)
            {
                base._get_property_listv(ref p_list, p_reversed);
            }
        }

        protected override void _notificationv(int p_notification, bool p_reversed)
        {
            if (!p_reversed)
                base._notificationv(p_notification, p_reversed);

            if (typeof(ConfigFile).GetMethod("_notification", Misc.BindingFlags_Greedy) != typeof(Reference).GetMethod("_notification", Misc.BindingFlags_Greedy))
            {
                _notification(p_notification);
            }

            if (p_reversed)
                base._notificationv(p_notification, p_reversed);
        }

        public static new string get_type_static() { return "ConfigFile"; }

        public static new string get_parent_type_static() { return Reference.get_type_static(); }

        public static new void get_inheritance_list_static(ref List<string> r_inheritance_list)
        {
            Reference.get_inheritance_list_static(ref r_inheritance_list);
            r_inheritance_list.Add(get_type_static());
        }

        public static new string get_category_static()
        {
            string category = Reference.get_category_static();
            if (typeof(ConfigFile).GetMethod("_get_category", Misc.BindingFlags_Greedy) != typeof(Reference).GetMethod("_get_category", Misc.BindingFlags_Greedy))
            {
                if (category != "")
                    category += "/";
                category += _get_category();
            }
            return category;
        }

        public static new string inherits_static() { return "Reference"; }

        public static new void get_valid_parents_static(ref List<string> p_parents)
        {
            if (typeof(ConfigFile).GetMethod("_get_valid_parents_static", Misc.BindingFlags_Greedy) != typeof(Reference).GetMethod("_get_valid_parents_static", Misc.BindingFlags_Greedy))
            {
                ConfigFile._get_valid_parents_static(ref p_parents);
            }

            Reference.get_valid_parents_static(ref p_parents);
        }

        public static new void initialize_type()
        {
            if (__initialized)
                return;
            Reference.initialize_type();
            ObjectTypeDB._add_type<ConfigFile>();

            SysMethodInfo cls_bind = typeof(ConfigFile).GetMethod("_bind_methods", Misc.BindingFlags_Greedy);
            SysMethodInfo par_bind = typeof(Reference).GetMethod("_bind_methods", Misc.BindingFlags_Greedy);
            if (cls_bind != par_bind)
                cls_bind.Invoke(null, null);
            __initialized = true;
        }

        private static bool __initialized = false;
        #endregion
    }
}
